#pragma once
#include <vector>
#include <d3dcompiler.h>


#include "RCInterfaces.h"
#include "RCGraphicsDevice.h"
#include "RCDrawableGameComponent.h"
#include "RCGameComponent.h"
#include "RCKeyboardStateManager.h"

using namespace RCDX11;
using namespace DirectX;

namespace RCDX11
{
	class RCGame : public IRCGame
	{
	protected:
		static int int_AppRunning;

		LPCTSTR str_Title;
		int int_XPos;
		int int_YPos;
		int int_Width;
		int int_Height;
	
		std::vector<IUpdateable*> vUpdateables;
		std::vector<IDrawable*> vDrawables;
		std::vector<std::shared_ptr<IRCGameComponent>> vGameComponents;

		XMFLOAT4 clearColor;
	
		static HWND hWnd;

		// Method to initialize the window
		DECLDIR virtual void Initialize(LPCTSTR str_Title,int int_XPos, int int_YPos, int int_Width, int int_Height, WNDPROC WinProc);

		DECLDIR virtual LRESULT CALLBACK WinProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );

	public:

		DECLDIR RCGame(void);
		DECLDIR virtual ~RCGame(void);

		// GraphicsDevice
		RCGraphicsDevice GraphicsDevice;

		// Keyboard manager
		RCKeyboardStateManager KeyboardManager;

		DECLDIR virtual void setTitle(LPCTSTR title);
		DECLDIR virtual void setWindowPos(int x, int y);
		DECLDIR virtual void setWindowDimension(int width, int height);

	

		DECLDIR virtual void Initialize();
	
		DECLDIR virtual void Update(float time, std::vector<IUpdateable*>* updateambles);	

		// Draw call
		DECLDIR virtual void Draw(float time, std::vector<IDrawable*>* drawables);
	
		DECLDIR static HRESULT CompileShaderFromFile( WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut );

		DECLDIR virtual void Run(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow);

		DECLDIR static void Stop();

		DECLDIR static LRESULT CALLBACK winProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
	

		DECLDIR virtual void AddComponent(std::shared_ptr<IRCGameComponent> component);

		DECLDIR virtual IRCGraphicsDevice* getGraphicsDevice();

		DECLDIR virtual void setClearColor(XMFLOAT4 color);

		DECLDIR static XMVECTOR GetTextureSize(_In_ ID3D11ShaderResourceView* texture);

	};

}